package com.luo.controller;

import com.alibaba.fastjson.JSON;
import com.luo.model.OneClass;
import com.luo.model.Result;
import com.luo.service.ClassService;
import com.luo.util.ListTypes;
import com.sun.xml.internal.fastinfoset.util.ValueArrayResourceException;
import org.aspectj.weaver.ast.Var;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;
import java.util.List;

/**
 * 功能：
 * 作者：Luo。
 * 日期：2024/1/14 11:19
 */
@WebServlet("/queryAllOneClass")
public class QueryAllOneClass extends HttpServlet {

    ClassService classService = new ClassService();
    Result result = new Result();

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<OneClass> oneClasses = classService.queryAllOneClass();
        List<Object> objList = ListTypes.getObjList(oneClasses);

        result.setCode("1");
        result.setMsg("查询成功");
        result.setResult(objList);
        String jsonString = JSON.toJSONString(result);

        resp.getWriter().write(jsonString);
        resp.getWriter().close();
    }
}
